<?php 
	$this->load->view('header');
	$deiscription	= $obj_data['cdescription'];
	//echo $deiscription;
?>

<meta property="og:title" content="<?php echo $obj_data['cproducts'] ?>" />
<meta property="og:description" content="<?php echo strip_tags($deiscription); ?>" />
<meta property="og:image" content="<?php echo base_url().'upload/images_product/resize_images/'.$obj_data['cimage_resize'] ?>" />

<?php
	$this->load->view('header_end');
	$this->load->view('part_view/mod_banner_header'); 
?>
<div id="block_menu_banner">
	<?php 
		$this->load->view('part_view/mod_menu_top'); 
	?>
</div>
<div id="content_block">
	<div id="left_column">
		<?php 
			$this->load->view('part_view/mod_check_search'); 
		?>
	</div>
	<div id="main_column_product">
		<div class="block_product">
			<div class="top_bar">
				<h3 class="title_page"><?php echo $obj_data['cproducts'] ?></h3>
				<div class="clear"></div>
			</div>
			<div class="content_box">
				<div class="site_map">
					<div class="inside">
						<div class="items_left">
							<a href="<?php echo base_url().'upload/images_product/full_images/'.$obj_data['cimage'] ?>" class="gallery" rel="full_image">
								<?php if($obj_data['cimage_resize'] !=''): ?>
									<img src="<?php echo base_url().'upload/images_product/full_images/'.$obj_data['cimage'] ?>" alt="<?php echo $obj_data['cproducts'] ?>" width="400" style="padding:2px;" />
								<?php else: ?>
									<img src="<?php echo base_url().'images/noimage.jpg'; ?>" alt="<?php echo 'noimage' ?>" width="209" height="200" />
								<?php endif; ?>
							</a>
							<p style="text-align:center">Click vào hình để phóng to</p>
						</div>
						<div class="infomation">
							<h3><?php echo $obj_data['cproducts'] ?></h3>
							<p style="color:#C76200; font-size:18px; font-weight:bold;">
								<?php 
									if($obj_data['fprice_sale'] != 0 && $obj_data['fprice_sale'] != '')
										echo show_price($obj_data['fprice_sale']).show_price_sale($obj_data['fprice']);
									else
										echo show_price($obj_data['fprice']);
								?>
							</p>
							<p style="margin:10px 0">
								<form id="frmProduct" name="frmProduct" action="<?php echo base_url().'product/add_cart/'.$obj_data['nid'] ?>" method="post">
									<?php if($obj_data['fprice'] == 0 || $obj_data['nid'] == ''){ ?>
										<a href="javascript: call_cart()" ><img src="<?php echo base_url().'images/btn_cart.png' ?>" alt="btn_cart" /></a>
									<?php } else { ?>
										<a href='javascript: add_cart(<?php echo $obj_data['nid'] ?>)'>
											<img src="<?php echo base_url().'images/btn_cart.png' ?>" alt="btn_cart" id="slidingProduct<?php echo $obj_data['nid'] ?>" />
										</a>
									<?php } ?>
								</form>
							</p>
							<p><b>Nhóm sản phẩm:</b> <br/>
							
							<?php 
								$secs	= Obj_get_material_product_byid($obj_data['nid_material_products']);
								foreach($secs as $sec):
							?>
								<a href="<?php echo base_url().'product/section/'.$sec['nid'] ?>"><?php echo $sec['cmaterial_products'];  ?></a>
									
							<?php endforeach; ?>
							<?php	
								$cats	= Obj_get_cat_product_byid($obj_data['nid_cat_products']);
								foreach($cats as $cat):
							?>
								<a href="<?php echo base_url().'product/list_product/'.$sec['nid'].'/'.$cat['nid'] ?>"><?php echo ' >> '.$cat['ccat_products'];  ?></a>	 
							<?php endforeach; ?>
							
							<?php	
								$brands	= Obj_get_brand_product_byid($obj_data['nid_brand_products']);
								foreach($brands as $brand):
							?>
								<a href="<?php echo base_url().'product/brand/'.$sec['nid'].'/'.$cat['nid'].'/'.$brand['nid'] ?>"><?php echo ' >> '.$brand['cbrand_products'];  ?></a>	 
							<?php endforeach; ?>
							
							<div class="info">
								<!--<p><b>Các tính năng công dụng:</b></p>-->
								<?php echo $obj_data['cdescription'] ?>
								
							</div>
						</div>
					</div>
					<div class="detail_product">
						<?php if($obj_data['cdetail'] != ''): ?>
						<div class="info">
							<h3>Thông tin chi tiết:</h3>
							<?php echo $obj_data['cdetail'] ?>
						</div>
						<?php endif; ?>
					</div>
					<div class="share_tool">
						<span class='st_fblike_hcount' displayText='Facebook Like'></span>
						<span class='st_facebook_hcount' displayText='Facebook'></span>
						<span class='st_twitter_hcount' displayText='Tweet'></span>
						<span class='st_email_hcount' displayText='Email'></span>
					</div>
					<script type="text/javascript">var switchTo5x=true;</script>
					<script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script>
					<script type="text/javascript">stLight.options({publisher: "fd08282f-4b6a-449a-a38b-0ec8abe705fc"});</script>
					
					<?php 
						$data_list = get_random_product($obj_data['nid_material_products'],$obj_data['nid_cat_products'],$obj_data['nid']);
						if(count($data_list) > 0):
					?>
					<div class="mod_relation_product">
						<h4 class="title_page" style="margin-top:15px;">Sản phẩm liên quan</h4>
						<div class="list_items">
							<?php  
								$count = 1;
								$num_colum = 5;	
								foreach($data_list as $data): 
							?>
							<?php if($count > 1 && $count%$num_colum == 1): ?>
							</div>
							<?php endif; ?>
							<?php if($count == 1 OR $count%$num_colum == 1 ): ?>
							<div class="row_product">
							<?php endif; ?>
								<?php if($count > 1 && $count%5==0): ?>
								<div class="item_product border_product last">
								<?php else: ?>
								<div class="item_product border_product">
								<?php endif; ?>
									<?php if($data['cimage_resize'] !=''): ?>
									<p><a href="<?php echo base_url().'product/detail/'.$data['nid'] ?>" onMouseOver="ShowTooltip('<?php echo base_url()."ajax/ajax_product/getid/".$data['nid'];?>'); return false;" onMouseOut="HideTooltip();"><img src="<?php echo base_url().'upload/images_product/resize_images/'.$data['cimage_resize'] ?>" alt="<?php echo $data['cproducts'] ?>"/></a></p>
									<?php else: ?>
									<p><a href="<?php echo base_url().'product/detail/'.$data['nid'] ?>" onMouseOver="ShowTooltip('<?php echo base_url()."ajax/ajax_product/getid/1";?>'); return false;" onMouseOut="HideTooltip();"><img src="<?php echo base_url().'images/noimage.jpg'; ?>" alt="<?php echo $data['cproducts'] ?>" width="170" height="135" class="img_fade"/></a></p>
									<?php endif; ?>
									<h4><a href="<?php echo base_url().'product/detail/'.$data['nid'] ?>"><?php echo $data['cproducts'] ?></a></h4>
									<p class="price">
										<?php 
											if($data['fprice_sale'] != 0 && $data['fprice_sale'] != '')
												echo show_price($data['fprice_sale']).show_price_sale($data['fprice']);
											else
												echo show_price($data['fprice']);
										?>
									</p>
								</div>			
							<?php if($count == count($data_list)): ?>
							</div>
							<?php endif; ?>
							<?php
								$count++;  
								endforeach; 
							?>
						</div>
					</div>
					<?php endif; ?>
				</div>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript">
	
	function add_cart(nid)
	{	
		//document.forms["frmProduct"].hidden_link.value = window.location.href;
		
		addToBasket(nid);

		setTimeout("submit3()",1000);		
	}
	function submit3()
	{
		document.forms["frmProduct"].submit();
	}
	
	function add_cart2(nid)
	{	
		//document.forms["frmProduct"].hidden_link.value = window.location.href;
		
		addToBasket(nid);

		setTimeout("submit2("+nid+")",1000);		
	}
	function submit2(nid)
	{
		f_form	= "frmProduct"+nid;
		document.forms[f_form].submit();
	}
	
	function call_cart()
	{
		alert(' <?php 
			$obj_data = get_config_byid(7);
			if(count($obj_data)>0):
				foreach($obj_data as $data):
					echo $data['cnote'];
				endforeach;
			endif;
		 ?>
');
	}
	

$(function() {
	$('.gallery').lightBox({
			imageLoading:			"<?php echo base_url().'js/img_lightbox/lightbox-ico-loading.gif' ?>",		// (string) Path and the name of the loading icon
			imageBtnPrev:			"<?php echo base_url().'js/img_lightbox/pre.png' ?>",			// (string) Path and the name of the prev button image
			imageBtnNext:			"<?php echo base_url().'js/img_lightbox/next.png' ?>",			// (string) Path and the name of the next button image
			imageBtnClose:			"<?php echo base_url().'js/img_lightbox/lightbox-btn-close.gif' ?>",		// (string) Path and the name of the close btn
			imageBlank:				"<?php echo base_url().'js/img_lightbox/lightbox-blank.gif' ?>",
		}
	);
});
	
</script>
<?php 
	$this->load->view('part_view/mod_home_slide_bottom'); 
	$this->load->view('part_view/mod_footer_content');  
	$this->load->view('footer');
?>


